import { GlobalEventMgr } from "../../platform/event/GlobalEventMgr";
import { IScript } from "../IScript";
import { Msg_Login_Resp, Msg_Resp } from "../msgs";
import { MsgTypes } from "../MsgTypes";
import { script } from "../NetManager";
import { SyncDemoEvent } from "../SyncDemoEvent";

@script()
export class LoginRespScript implements IScript<Msg_Login_Resp> {
    getType(): string {
        return MsgTypes.Login;
    }
    handle(msg: Msg_Resp<Msg_Login_Resp>): void {
        if(msg.code != 0){
            console.error("登录失败："+msg.code);
            return
        }
        GlobalEventMgr.ins.emit(SyncDemoEvent.LoginSuccess, msg.data);
    }
}